<?php

class BgimageModel {

    private $conn = null;

    function __construct() {
        $this->conn = new mysqlconnect(Yaf_Registry::get('dbconfig'));
        $this->conn->connect();
    }

    public function fetchBgimageByMenuid($menu_id) {
        $sql = 'SELECT * FROM bg_image WHERE menu_id=? ORDER BY order_id';
        $result = $this->conn->fetch($sql,$menu_id);

        return $result;
    }
    public function fetchBgimageById($id)
    {
        $sql = 'SELECT * FROM bg_image WHERE id=?';
        $result = $this->conn->fetch($sql,$id);
        
        return $result;
    }
    public function fetchMenu()
    {
        $sql = 'SELECT * FROM menu';
        $result = $this->conn->fetch($sql);
        return $result;
    }
    public function insertBgimage($data) {
        return $this->conn->insert('bg_image', $data);
    }

    public function updateBgimage($data, $condition) {
        $this->conn->update('bg_image', $data, $condition);
    }

    public function delete($table,$condition)
    {
        $this->conn->delete($table,$condition);
    }
}

?>
